<template>
  <div class="index">
    <top/>
    <div class="main">
      <keep-alive>
        <router-view style="flex:1;"/>
      </keep-alive>
      <foot/>
    </div>
  </div>
</template>

<script>
import Top from "./nav/top";
import Foot from "./nav/foot";
export default {
  components: {
    Top,
    Foot
  },
  data(){
    return{
    }
  },
  methods:{
	  /** 在刷新和关闭之前询问 **/
	  	beforeRefreshClose() {
	  		let self = this;
	  		window.onbeforeunload = function (e) {
	  			if (self.$route.name == "路由名称") {
	  				e = e || window.event;
	  				// 兼容IE8和Firefox 4之前的版本
	  				if (e) e.returnValue = "关闭提示1";
	  				// Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
	  				return "关闭提示2";
	  			} else window.onbeforeunload = null;
	  		};
	  	},
  },
  mounted(){
    this.$store.dispatch('commonActions')
	  this.beforeRefreshClose()
  }
}
</script>

<style lang="scss" scoped>
.index {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #fff;
}
.main{
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
</style>
